<template>
  <a-card>
    <div :class="advanced ? 'search' : null">
        <detail-list title="">
          <detail-list-item term="RFID">1000000000</detail-list-item>
          <detail-list-item term="设备名称">已取货</detail-list-item>
          <detail-list-item term="所属线体">3*21</detail-list-item>
        </detail-list>
      <a-form layout="horizontal">
        <div :class="advanced ? null: 'fold'">
            <a-row >
            <a-col v-if="active=='1'" :md="8" :sm="24" >
                <a-form-item
                label="绑定时间"
                :labelCol="{span: 5}"
                :wrapperCol="{span: 18, offset: 1}"
                >
                <a-range-picker @change="onChange" />
                </a-form-item>
            </a-col>
            <a-col v-if="active!='1'" :md="8" :sm="24" >
                <a-form-item
                label="进站时间"
                :labelCol="{span: 5}"
                :wrapperCol="{span: 18, offset: 1}"
                >
                <a-range-picker @change="onChange" />
                </a-form-item>
            </a-col>
            <a-col v-if="active=='1'" :md="8" :sm="24" >
            <a-form-item
              label="产品ID"
              :labelCol="{span: 5}"
              :wrapperCol="{span: 18, offset: 1}"
            >
              <a-input-number style="width: 100%" placeholder="请输入产品ID" />
            </a-form-item>
          </a-col>
            </a-row>
          <a-row >
          <a-col v-if="active=='1'" :md="8" :sm="24" >
            <a-form-item
              label="RFID"
              :labelCol="{span: 5}"
              :wrapperCol="{span: 18, offset: 1}"
            >
              <a-input-number style="width: 100%" placeholder="请输入RFID" />
            </a-form-item>
          </a-col>
          <a-col v-if="active!='1'" :md="4" :sm="24" >
            <a-form-item
              label=""
              :labelCol="{span: 5}"
              :wrapperCol="{span: 18, offset: 1}"
            >
              <a-select default-value="lucy" style="width: 120px" @change="handleChange">
                <a-select-option value="jack">
                    Jack
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col v-if="active!='1'" :md="4" :sm="24" >
            <a-form-item
              label=""
              :labelCol="{span: 5}"
              :wrapperCol="{span: 18, offset: 1}"
            >
              <a-select default-value="lucy" style="width: 120px" @change="handleChange">
                <a-select-option value="jack">
                    Jack
                </a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
        </div>
        <span style="float: right; margin-top: 3px;">
          <a-button type="primary">查询</a-button>
          <a-button style="margin-left: 8px">重置</a-button>
          <a @click="toggleAdvanced" style="margin-left: 8px">
            {{advanced ? '收起' : '展开'}}
            <a-icon :type="advanced ? 'up' : 'down'" />
          </a>
        </span>
      </a-form>
    </div>
    <div>
        <a-tabs :default-active-key="1" v-model="active" @change="callback">
      <a-tab-pane key="1" tab="产品列表">
        <standard-table
        :scroll="tableScroll"
        :columns="columns"
        :dataSource="dataSource"
        :selectedRows.sync="selectedRows"
        @clear="onClear"
        @change="onChange"
        @selectedRowChange="onSelectChange"
      >
      </standard-table>
      </a-tab-pane>
      <a-tab-pane key="2" tab="工位列表">
        <standard-table
        :scroll="tableScroll"
        :columns="lineColumns"
        :dataSource="dataSource"
        :selectedRows.sync="selectedRows"
        @clear="onClear"
        @change="onChange"
        @selectedRowChange="onSelectChange"
      >
      </standard-table>
      </a-tab-pane>
    </a-tabs>
      
    </div>
  </a-card>
</template>

<script>
import DetailList from '@/components/tool/DetailList'
const DetailListItem = DetailList.Item
import StandardTable from '@/components/table/StandardTable'
const columns = [
  {
    title: '序号',
    dataIndex: 'no'
  },
  {
    title: '产品ID',
    dataIndex: 'no'
  },
  {
    title: '产品类型',
    dataIndex: 'description',
    scopedSlots: { customRender: 'description' }
  },
  {
    title: '工位',
    dataIndex: 'updatedAt',
    sorter: true
  },
  {
    title: '绑定时间',
    dataIndex: 'updatedAt',
  },
  {
    title: '解绑时间',
    dataIndex: '',
  }
]
const lineColumns = [
    {
    title: '序号',
    dataIndex: 'no'
  },
  {
    title: '线体',
    dataIndex: 'no'
  },
  {
    title: '工艺段',
    dataIndex: 'description',
    scopedSlots: { customRender: 'description' }
  },
  {
    title: '工位',
    dataIndex: 'updatedAt',
    sorter: true
  },
  {
    title: '设备',
    dataIndex: 'updatedAt',
  },
  {
    title: '进站时间',
    dataIndex: '',
  },
  {
    title: '出战时间',
    dataIndex: 'updatedAt',
  }

]
const dataSource = []

for (let i = 0; i < 100; i++) {
  dataSource.push({
    key: i,
    no: 'NO ' + i,
    description: '这是一段描述',
    callNo: Math.floor(Math.random() * 1000),
    status: Math.floor(Math.random() * 10) % 4,
    updatedAt: '2018-07-26'
  })
}

export default {
  name: 'QueryList',
  components: {StandardTable,DetailListItem,DetailList},
  data () {
    return {
      isLineBody:false,
      advanced: false,
      active:'1',
      columns: columns,
      lineColumns,
      dataSource: dataSource,
      lineDataSource:[],
      selectedRows: []
    }
  },
  authorize: {
    deleteRecord: 'delete'
  },
  computed:{
      getWidth: function () {
      if (this.defColumns.length > 10) {
        return { width: "500px" };
      }
    },
    tableScroll: function () {
      if (this.columns.length > 10) {
        return { x: 800, y: 450 };
      }
    },
  },
  methods: {
    deleteRecord(key) {
      this.dataSource = this.dataSource.filter(item => item.key !== key)
      this.selectedRows = this.selectedRows.filter(item => item.key !== key)
    },
    toggleAdvanced () {
      this.advanced = !this.advanced
    },
    remove () {
      this.dataSource = this.dataSource.filter(item => this.selectedRows.findIndex(row => row.key === item.key) === -1)
      this.selectedRows = []
    },
    onClear() {
      this.$message.info('您清空了勾选的所有行')
    },
    onStatusTitleClick() {
      this.$message.info('你点击了状态栏表头')
    },
    onChange() {
      this.$message.info('表格状态改变了')
    },
    onSelectChange() {
      this.$message.info('选中行改变了')
    },
    addNew () {
      this.dataSource.unshift({
        key: this.dataSource.length,
        no: 'NO ' + this.dataSource.length,
        description: '这是一段描述',
        callNo: Math.floor(Math.random() * 1000),
        status: Math.floor(Math.random() * 10) % 4,
        updatedAt: '2018-07-26'
      })
    },
    handleMenuClick (e) {
      if (e.key === 'delete') {
        this.remove()
      }
    }
  }
}
</script>

<style lang="less" scoped>
  .search{
    margin-bottom: 54px;
  }
  .fold{
    width: calc(100% - 216px);
    display: inline-block
  }
  .operator{
    margin-bottom: 18px;
  }
  .tabs-uhn{
    width: 70%;
    text-align: center;
    padding:12px 0px;
    box-shadow: 3px 3px 3px#E7EAED;
    border-radius: 9px;
    background-color: #F2F2F2;
  }
  @media screen and (max-width: 900px) {
    .fold {
      width: 100%;
    }
  }
</style>
